import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.util.List;

public class ObjectMapperDemo {
    public static void main(String[] args) {
        String jsonString = """
        [
        {"brand":"XiaoMi","model":"Yu7","city":"Guangzhou","year":2025},
        {"brand":"Lixiang","model":"i8","city":"Beijing","year":2023},
        {"brand":"Huawei","model":"M5","city":"Shenzhen","year":2024}
        ]
        """;
        ObjectMapper mapper = new ObjectMapper();
        //mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,flase);
        try {
            Car[] myCar = mapper.readValue(jsonString, Car[].class);
            //List<Car> myCar = mapper.readValue(jsonString, new TypeReference<List<Car>>(){});
            for(Car car : myCar){
                System.out.println(car.toString());
            }
        }catch (JsonProcessingException e){
            throw new RuntimeException(e);
        }
    }
}
